package com.sp.app.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description:日期处理�? 
 * @author: Caox
 * @createTime: 2017�?12�?12�? 下午2:47:44 
 */
public class DateUtil {

	public static String Date2String(Date date)throws Exception{
		return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
	}
	
	public static Date String2Date(String strDate)throws Exception{
		return new SimpleDateFormat("yyyy-MM-dd").parse(strDate);
	}
	
	public static String getStringToday() {
		   Date currentTime = new Date();
		   SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		   String dateString = formatter.format(currentTime);
		   return dateString;
		}
	
	public static String getHour() {
		   Date currentTime = new Date();
		   SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		   String dateString = formatter.format(currentTime);
		   String hour;
		   hour = dateString.substring(11, 13);
		   return hour;
		}
	
	public static String getTime() {
		   Date currentTime = new Date();
		   SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		   String dateString = formatter.format(currentTime);
		   String min;
		   min = dateString.substring(14, 16);
		   return min;
		}
}
